package com.qingcheng.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.qingcheng.dao.ReplyMerchantMapper;
import com.qingcheng.pojo.comment.ReplyMerchant;
import com.qingcheng.service.comment.ReplyMerchantService;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;

@Service
public class ReplyMerchantServiceImpl implements ReplyMerchantService {

    @Autowired
    private ReplyMerchantMapper replyMerchantMapper;

    public void replyMerchant(ReplyMerchant replyMerchant) {

        replyMerchant.setCreateTime(new Date());
        replyMerchant.setShopId(1);
        replyMerchant.setIsDelete(0);
        replyMerchant.setShopName("青橙");
        replyMerchantMapper.insert(replyMerchant);
    }

    public ReplyMerchant findByCommentId(Integer commentId) {
        Example example = new Example(ReplyMerchant.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("commentId",commentId);
        List<ReplyMerchant> replyMerchants = replyMerchantMapper.selectByExample(example);
        if (replyMerchants.size()==0){
            return null;
        }else {
            return replyMerchants.get(0);
        }

    }
}
